package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Region;
import cn.wolfcode.trip.base.mapper.RegionMapper;
import cn.wolfcode.trip.base.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RegionServiceImpl implements IRegionService{
    @Autowired
    private RegionMapper regionMapper;


    @Override
    public List<Region> getRegionByParentId(Long parentId) {
        return regionMapper.getRegionByParentId(parentId);
    }

    @Override
    public List<Region> list() {
        return regionMapper.selectAll();
    }

    @Override
    public void saveOrUpdate(Region region) {
        if(region.getId()==null){
            regionMapper.insert(region);
        }else{
            regionMapper.updateByPrimaryKey(region);
        }
    }

    @Override
    public List<Region> listHot(Integer stateId) {
        return regionMapper.listHot(stateId);
    }

}
